package com.music.mysongs.activity

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.music.mysongs.R
import com.music.mysongs.fragment.option.*
import com.music.mysongs.utils.BaseActivity
import com.music.mysongs.utils.myLog
import kotlinx.android.synthetic.main.activity_option.*

class OptionActivity : BaseActivity() {
    private val mTAG = "OptionActivity"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_option)
        val bundle = intent.extras
        val option = bundle?.getString("_option")
        myLog("$mTAG: option=$option")
        if (savedInstanceState == null) {
            when (option) {
                "op_post" -> {//main
                    txtTitle_option.text = "发送作品"
                    changeFra(PostFragment())
                }
                "op_account" -> {//mine
                    txtTitle_option.text = "修改资料"
                    changeFra(AccountFragment())
                }
                "op_collection" -> {//mine
                    txtTitle_option.text = "管理作品"
                    changeFra(CollectionFragment())
                }
                "op_history" -> {//mine
                    txtTitle_option.text = "历史今日"
                    changeFra(HistoryFragment())
                }
                "op_songMsg" -> {//song
                    txtTitle_option.text = "唠嗑中心"
                    changeFra(SongMsgFragment())
                }
                else -> {
                    myLog("$mTAG: op=$option")
                }
            }
        }
    }

    private fun changeFra(newFra: Fragment) {
        supportFragmentManager.beginTransaction().replace(R.id.layoutFragment_option, newFra)
            .commit()
    }
}